<?php

	include_once("CONN.php");
	
	session_start();
	if(isset($_POST["sub"]) && $_POST["sub"] == "登录"){
		$sql1 = "select * from user where userName ='".$_POST['userName']."'";
		$res = mysqli_query($connID,$sql1);
		while($row0 = mysqli_fetch_row($res)){
			if ($row0[1] == $_POST['userName']){
				if($row0[2] == $_POST['passWord']){
					$_SESSION["userName"] = $_POST['userName'];
					$_SESSION["passWord"] = $_POST['passWord'];
					echo"<script>alert ('登录成功！')</script>";
					echo "<script> window.location.href='../HTML/index.php' </script>";
				}else{
					echo"<script>alert ('密码错误！')</script>";
					echo "<script> window.location.href='../HTML/login.html' </script>";
				}
			}else{
				
			}
		}
		echo"<script>alert ('用户名不存在！')</script>";
		echo "<script> window.location.href='../HTML/login.html' </script>";
	}
?>
